#!/bin/sh

# 函数用于居中输出红字信息
center_text() {
    termwidth="$(tput cols)"
    padding="$(printf '%0.1s' ={1..500})"
    text="$1"
    printf '\033[31m%*.*s %s %*.*s\033[0m\n' 0 "$(((termwidth-2-${#text})/2))" "$padding" "$text" 0 "$(((termwidth-1-${#text})/2))" "$padding"
}

# 检测操作系统类型
if [ -f /etc/os-release ]; then
    . /etc/os-release
    OS=$ID
elif [ -f /etc/centos-release ]; then
    OS=centos
else
    center_text "Unsupported OS"
    exit 1
fi

# 输出检测到的系统类型
center_text "您的系统是 $OS"
center_text "正在执行$OS系统的安装脚本..."

# 根据操作系统类型执行对应的安装命令
case $OS in
    centos)
        URL=https://www.aapanel.com/script/install_7.0_en.sh && if [ -f /usr/bin/curl ];then curl -ksSO "$URL" ;else wget --no-check-certificate -O install_7.0_en.sh "$URL";fi;bash install_7.0_en.sh aapanel
        ;;
    ubuntu|deepin)
        URL=https://www.aapanel.com/script/install_7.0_en.sh && if [ -f /usr/bin/curl ];then curl -ksSO "$URL" ;else wget --no-check-certificate -O install_7.0_en.sh "$URL";fi;bash install_7.0_en.sh aapanel
        ;;
    debian)
        URL=https://www.aapanel.com/script/install_7.0_en.sh && if [ -f /usr/bin/curl ];then curl -ksSO "$URL" ;else wget --no-check-certificate -O install_7.0_en.sh "$URL";fi;bash install_7.0_en.sh aapanel
        ;;
    *)
        center_text "Unsupported OS: $OS"
        exit 1
        ;;
esac
